<!DOCTYPE html>
<html>
<head>
    <meta charset="utf-8">
    <title>Title</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=no"/>
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>
    <meta name="renderer" content="webkit">
    <link rel="stylesheet" href="/mdui/css/mdui.min.css">
    <script defer src="/mdui/js/mdui.min.js"></script>
    <script src="/js/axios.min.js"></script>
    <script src="/js/qs.min.js"></script>
    <script src="/js/common.js"></script>
    <script src="/js/vue.js"></script>

    <style>
        .mdui-table-fluid {
            width: 1200px;
        }

        .mdui-table {
            border: 1px solid #d6d6d6;
        }

        .mdui-btn {
            margin-right: 100px;
        }

        a {
            text-decoration: none;
        }

        .mdui-table-fluid {
            width: 800px;
        }

        .mdui-table td img {
            height: 100px;
            width: 140px;
        }

        .mdui-textfield-input1 {
            border: 0;
            height: 30px;
            width: 130px;
            border: 1px solid #d6d6d6;
        }

        .mdui-btn-dense {
            margin-top: 10px;
            width: 800px;
            height: 40px;
        }

        .mdui-btn {
            width: 800px;
        }
    </style>
</head>
<body class="mdui-theme-primary-indigo mdui-theme-accent-green">
<div class="mdui-container-fluid" id="app">
    <h1 class="mdui-text-color-theme">水电缴费</h1>
    <div class="mdui-table-fluid">
        <table class="mdui-table">
            <thead>
            <tr>
                <th>缴费类型</th>
                <th>金额</th>
            </tr>
            </thead>
            <tbody>
            <tr>
                <td>宿舍</td>
                <td><input class=" mdui-textfield-input1" type="text" v-model="door.name" name="detail" readonly/>
                </td>
            </tr>
            <tr>
                <td>水费</td>
                <td><input class=" mdui-textfield-input1" type="text" v-model="door.water"
                           name="detail"/></td>
            </tr>
            <tr>
                <td>电费</td>
                <td><input class=" mdui-textfield-input1" type="" v-model="door.power" name="detail"/>
                </td>
            </tr>
            </tbody>
        </table>
    </div>
    <button class="mdui-btn mdui-btn-dense mdui-color-theme-accent mdui-ripple mdui-color-green-800"
            @click="Payment">
        确认缴费
    </button>
</div>
</body>

<script>
    let params = new URLSearchParams(location.search);//location.searc url中参数的部分包括问号
    let repairid = params.get("id")
    new Vue({
        el: '#app',
        data: {
            door: {
                name: "",
                water: "",
                power: ""
            },
        },
        created() {
            let _this = this
            axios.get("/door/findDoor")
                .then(function (res) {
                    _this.door = res.data;
                    console.log(res.data)
                })
        },

        methods: {
            Payment() {
                if (this.door.water == "" || this.door.power == "") {
                    mdui.alert("金额不能为空")
                    return;
                }
                let _this = this;
                axios.post("/door/payment", this.door)
                    .then(function (res) {
                        if (res.data.success) {
                            mdui.alert("缴费成功");
                            _this.door.water = ''
                            _this.door.power = ''
                        }
                    })
                //window.location.href = "list.html";
                console.log(_this.door)
            },
        }
    })
</script>
</body>
</html>